home *** CD-ROM | disk | FTP | other *** search
/ Word Perfect Main Street:…th Treasure of the Tombs / WordPerfect Main Street - Memphis Math Treasure of the Tombs.iso / cdefs.hpp < prev    next >
Text File  |  1994-08-26  |  9KB  |  198 lines

  1. //=============================================================================
  2. //CDEFS.HPP
  3. //  Waterford Sandy common definitions.
  4. //
  5. //  Version  Date     Comment
  6. //        0.9  081894   pre-release
  7. //        1.0  082594   release
  8. //
  9. //  Required link libraries: -none-
  10. //  Tab size: 2
  11. //=============================================================================
  12.  
  13. /* exclude multiple includes */
  14. #if !defined (__CDEFS_HPP)
  15. #define __CDEFS_HPP
  16.  
  17. /* include files */
  18. #if !defined (__NOINCLUDE)
  19.     #ifndef __WINDOWS_H
  20.         #include <windows.h>
  21.     #endif
  22. #endif
  23.  
  24. /* exception codes: 80386+ exception codes */
  25. #define EXC_DIVIDE                        0                                                            //divide error
  26. #define EXC_DEBUG                            1                                                            //debugger interrupt
  27. #define EXC_NMI                                2                                                            //nonmaskable-interrupt
  28. #define EXC_BREAKPOINT                3                                                            //breakpoint
  29. #define EXC_OVERFLOW                    4                                                            //interrupt on overflow (INTO)
  30. #define EXC_ARRAYBOUND                5                                                            //array boundary violation (BOUND)
  31. #define EXC_INVOPCODE                    6                                                            //invalid opcode
  32. #define EXC_COPROCESSORNA            7                                                            //coprocessor not available
  33. #define EXC_DOUBLEFAULT                8                                                            //double fault
  34. #define EXC_COPROCESSORSEG        9                                                            //coprocessor segment overrun
  35. #define EXC_INVALIDTSS                10                                                        //invalid TSS (task state segment)
  36. #define EXC_SEGMENTNOTPRESENT    11                                                        //segment not present
  37. #define EXC_STACK                            12                                                        //stack exception
  38. #define EXC_GP                                13                                                        //general protectin violation
  39. #define EXC_PAGEFAULT                    14                                                        //page fault
  40. #define EXC_COPROCESSORERR        16                                                        //coprocessor error
  41. #define EXC_ALIGNMENT                    17                                                        //alignment check (80486+)
  42.  
  43. /* exit codes: use when returning from WinMain */
  44. #define EXIT_NORMAL                        0                                                            //returning normally
  45. #define EXIT_INVALIDPARAM            1                                                            //invalid command line parameter/argument
  46. #define EXIT_NOMEMORY                    2                                                            //unable to allocate necessary memory
  47. #define EXIT_INVALIDCONFIG        3                                                            //invalid system configuration
  48. #define EXIT_ASSERTIONFAILED    101                                                        //assertion failed
  49. #define EXIT_INVALIDTAG                102                                                        //invalid object tag
  50.  
  51. /* length definitions, not including NULL terminator */
  52. #define CBMAX_STRING                    255                                                        //general purpose string length
  53. #define CBMAX_RCSTRING                255                                                        //max resource string length
  54. #define CBMAX_PATHFILE                127                                                        //max path and file length
  55. #define CBMAX_PATH                        127                                                        //max path length
  56. #define CBMAX_DRIVE                        2                                                            //max drive letter and colon length
  57. #define CBMAX_FILENAME                8                                                            //max file name without extension length
  58. #define CBMAX_EXT                            3                                                            //max extension length, not including separating period
  59. #define CBMAX_FILE                        (CBMAX_FILENAME+1+CBMAX_EXT)    //max file, dot, extension
  60. #define CBMAX_PROFILE_NAME        (CBMAX_FILE)                                    //max profile name length
  61. #define CBMAX_PROFILE_SECTION    80                                                        //max profile section name length
  62. #define CBMAX_PROFILE_ENTRY        80                                                        //max profile entry name length
  63.  
  64. /* helper macros */
  65. #define PUBLIC                                                                                            //public (global) scope
  66. #define PRIVATE                                static                                                //private (local) scope
  67. #define IMPORT                                extern                                                //import data
  68. #define EXPORT                                                                                            //export data
  69. #if !defined (NULL)
  70.     #define NULL                                0                                                            //NULL value
  71. #endif
  72. #define FALSE                                    0
  73. #define TRUE                                    1
  74. #define GARBAGE                                0xCC                                                    //easily recognizable garbage value (204d  11001100b)
  75. #define PALVERSION                        0x0300                                                //palette version
  76. #define MIN(a,b)                        (((a)<(b))?(a):(b))                        //minimum value macro, use with caution
  77. #define MAX(a,b)                        (((a)>(b))?(a):(b))                        //maximum value macro, use with caution
  78. #define ROUND(val,type)                ((type)((val)+(((val)<0.0)?(-0.5):(0.5))))    //round value of specified type
  79. #define SETBITFLAG(bf,dest)        ((dest)|=(bf))                                //set bitflags in dest
  80. #define CLEARBITFLAG(bf,dest)    ((dest)&=(~(bf)))                            //clear bitflags in dest
  81. #define ISBITFLAGSET(bf,val)    ((val)&(bf))                                    //test bitflags in val
  82. #define SETBIT(bit,dest)            ((dest)|=(1<<(bit)))                    //set bit
  83. #define CLEARBIT(bit,dest)        ((dest)&=(~(1<<(bit))))                //clear bit
  84. #define ISBITSET(bit,val)            ((val)&(1<<(bit)))                        //test bit
  85. #if defined (SELECTOROF)                                                                        //default SELECTOROF macro doesn't convert to far pointer
  86.     #undef SELECTOROF
  87. #endif
  88. #define SELECTOROF(lp)                ((UINT)HIWORD((void far *)lp))
  89. #if defined (OFFSETOF)                                                                            //default OFFSETOF macro doesn't convert to far pointer
  90.     #undef OFFSETOF
  91. #endif
  92. #define OFFSETOF(lp)                    ((UINT)LOWORD((void far *)lp))
  93. #define RECTWIDTH(rc)                    ((rc).right-(rc).left)                //width of normalized rect
  94. #define RECTHEIGHT(rc)                ((rc).bottom-(rc).top)                //height of normalized rect
  95. #define FIELDSIZE(type,field)    ((UINT)(sizeof(((type near *)1)->field)))        //size of field in structure
  96. #define GlobalLockCount(hg)        (GlobalFlags(hg)&GMEM_LOCKCOUNT)        //lock count of global object
  97. #define GlobalIsDiscarded(hg)    (GlobalFlags(hg)&GMEM_DISCARDED)        //discarded test of global object
  98.  
  99. /* type defintions */
  100. #if !defined (RC_INVOKED)                                                                        //exclude non-resource definitions
  101. #define HUGE                                    _huge                                                    //misc types
  102. #define VOID                                    void
  103. typedef unsigned int *                PUINT;
  104. typedef unsigned long int            ULONG;
  105. typedef char                                    CHAR;
  106. typedef struct tagDIMS {                                                                        //dimension structure: left, top, width, height
  107.     int left;
  108.     int top;
  109.     int width;
  110.     int height;
  111. }                                                            DIMS,
  112. *                                                            PDIMS,
  113. near *                                                NPDIMS,
  114. far *                                                    LPDIMS;
  115. typedef int                                        INT;
  116. typedef signed char                        INT8;                                                    //fixed bit width types
  117. typedef int                                        INT16;
  118. typedef long int                            INT32;
  119. typedef unsigned char                    UINT8;
  120. typedef unsigned int                    UINT16;
  121. typedef unsigned long int            UINT32;
  122. typedef char                                    SZ;                                                        //NULL terminated string
  123. typedef char *                                PSZ;
  124. typedef char near *                        NPSZ;
  125. typedef char far *                        LPSZ;
  126. typedef float                                    FLOAT;                                                //floating point
  127. typedef double                                DPFLOAT;
  128. typedef double                                DOUBLE;
  129. typedef void *                                PVOID;                                                //void pointers
  130. typedef void near *                        NPVOID;
  131.  
  132. /* assertion macros */
  133. //Conditional compile defines
  134. //    __ASSERT - use macros, automatically turned on if debug defined, unless specifically turned off
  135. //    __NOASSERT - do not use macros
  136. //
  137. //Macros
  138. //    ASSERT (condition) - Asserts that the specified condition is true.
  139. #if defined ( __DEBUG)
  140.     #if !defined (__NOASSERT)
  141.         #define __ASSERT
  142.     #endif
  143. #endif
  144. #if defined (__ASSERT)
  145.     #define ASSERT(c)                        { \
  146.                                                                 if (!(c)) { \
  147.                                                                     SZ sz[60+1]; \
  148.                                                                     wsprintf(sz, "Module %s, %u\nTerminate application?", (LPSZ)__FILE__, (UINT)__LINE__); \
  149.                                                                     if (MessageBox (NULL, sz, "FAILURE: Assertion", MB_YESNO|MB_SYSTEMMODAL) == IDYES) \
  150.                                                                         exit (EXIT_ASSERTIONFAILED); \
  151.                                                                     asm int 3; \
  152.                                                                 } \
  153.                                                             }
  154. #else
  155.     #define ASSERT(c)                        0
  156. #endif
  157.  
  158. /* tag definitions/macros */
  159. //Conditional compile defines
  160. //    __TAG - use macros, automatically turned on if debug defined, unless specifically turned off
  161. //    __NOTAG - do not use macros
  162. //
  163. //Types
  164. //    TAG - Tag type
  165. //
  166. //Macros
  167. //    MAKE_TAG (c0, c1, c2, c3) - Macro that takes four characters and returns a tag value.
  168. //    VALIDATE_TAG (tag, definition) - Validates a tag against its definition.
  169. #if defined (__DEBUG)
  170.     #if !defined (__NOTAG)
  171.         #define __TAG
  172.     #endif
  173. #endif
  174. typedef unsigned long                    TAG;
  175. #define MAKE_TAG(c0,c1,c2,c3)    ((TAG)(BYTE)(c0)|((TAG)(BYTE)(c1)<<8)|((TAG)(BYTE)(c2)<<16)|((TAG)(BYTE)(c3)<<24))
  176. #if defined (__TAG)
  177.     #define VALIDATE_TAG(t,def)    { \
  178.                                                                 if ((t) != (def)) { \
  179.                                                                     SZ sz[60+1]; \
  180.                                                                     wsprintf (sz, "Module %s, %u : tag ('%c%c%c%c')\nTerminate application?", (LPSZ)__FILE__, (UINT)__LINE__, (CHAR)def, (CHAR)(def>>8), (CHAR)(def>>16), (CHAR)(def>>24)); \
  181.                                                                     if (MessageBox (NULL, sz, "FAILURE: Tag validation", MB_YESNO|MB_SYSTEMMODAL) == IDYES) \
  182.                                                                         exit (EXIT_INVALIDTAG); \
  183.                                                                     asm int 3; \
  184.                                                                 } \
  185.                                                             }
  186. #else
  187.     #define VALIDATE_TAG(t,d)        0
  188. #endif
  189.  
  190. #if defined (__TAG) || defined (__ASSERT)
  191.     extern "C" void _cdecl exit (int);        //required for assert and object tagging
  192. #endif
  193.  
  194. #endif //RC_INVOKED
  195.  
  196. #endif //__CDEFS_HPP
  197.  
  198.